// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import axios from 'axios'
import App from './App'
import router from './router'
import commonJson from '../static/js/common';

import { AlertPlugin, ToastPlugin } from 'vux'

Vue.use(AlertPlugin)
Vue.use(ToastPlugin)
Vue.prototype.axios = axios;
Vue.config.productionTip = false

Vue.filter('filterSize', function (spec_names,spec_value_names) {
  if (spec_names) {
    var specNamesText = '',specSizeText = '',specText = '';
        specNamesText = spec_names.split(','); 
        specSizeText = spec_value_names.split(','); 
        for (var a = 0; a < specNamesText.length; a++) {
          specText += specNamesText[a] + ':' + specSizeText[a] + '  ';
        }
        return specText;
  }
})

Vue.filter('dealImg', function (param) {
  if(param.indexOf(',') != -1){
		param = param.split(',')[0];
		if(param.indexOf('zhibodianshang/upload/') != -1) {
			return domainImgName + param.split('zhibodianshang/upload')[1];
		} else if(param.indexOf('putaotang/upload') != -1) {
			return domainImgName + param.split('putaotang/upload')[1];
		} else if(param.indexOf('http') != -1) {
			return param;
		} else {
			return commonJson.commonData().domainImgName + param;
		}
	}else{
		if(param.indexOf('zhibodianshang/upload/') != -1) {
			return domainImgName + param.split('zhibodianshang/upload')[1];
		} else if(param.indexOf('putaotang/upload') != -1) {
			return domainImgName + param.split('putaotang/upload')[1];
		} else if(param.indexOf('http') != -1) {
			return param;
		} else {
			return commonJson.commonData().domainImgName + param;
		}		
	}
})
/* eslint-disable no-new */
new Vue({
  router,
  render: h => h(App)
}).$mount('#app-box')
